package com.zjitc.serviceedu.mapper;

import com.zjitc.common.utils.RespBean;
import com.zjitc.serviceedu.entity.EduCourse;
import com.zjitc.serviceedu.entity.EduWatchhistory;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zjitc.serviceedu.entity.vo.WatchHistoryVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 赵诚挚
 * @since 2024-10-19
 */
public interface EduWatchhistoryMapper extends BaseMapper<EduWatchhistory> {
    @Insert("INSERT INTO edu_watchhistory (user_id,vid, course_id, video_id, last_position, gmt_create, gmt_modified) " +
            "VALUES (#{userId},#{vid}, #{courseId}, #{videoId}, #{lastPosition}, NOW(), NOW())")
    void insertWatchHistory(EduWatchhistory watchHistory);

    @Update("UPDATE edu_watchhistory SET last_position = #{lastPosition}, gmt_modified = NOW() " +
            "WHERE user_id = #{userId} AND video_id = #{videoId}")
    void updateWatchHistory(EduWatchhistory watchHistory);

    EduWatchhistory getWatchHistory(@Param("userId") Long userId, @Param("videoId") String videoId);

    List<WatchHistoryVO> getWatchHistoryList(@Param("userId") Long userId);
}
